package com.examination.system.administrator.controller;

import com.examination.api.administrator.AreaTypeControllerApi;
import com.examination.framework.model.response.QueryResponseResult;
import com.examination.framework.model.response.ResponseResult;
import com.examination.system.administration.AreaType;
import com.examination.system.administration.response.AddAdministrationResult;
import com.examination.system.administration.response.DeleteAdministrationResult;
import com.examination.system.administrator.service.AreaTypeService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 寇淇芮
 * @Date 2019/8/27 14:15
 */
@RestController
@RequestMapping("/administrator/areaType")
public class AreaTypeController implements AreaTypeControllerApi {
    @Autowired
    private AreaTypeService areaTypeService;
    @Override
    @PostMapping("/add")
    public AddAdministrationResult addAreaType(@RequestBody AreaType areaType) {
        return areaTypeService.addAreaType(areaType);
    }

    @Override
    @GetMapping("/list/{pages}/{size}")
    public QueryResponseResult findAreaType(@PathVariable("pages") Integer pages,
                                            @PathVariable("size") Integer size) {
        return areaTypeService.findAreaType(pages,size);
    }

    @Override
    @DeleteMapping("/delect/{id}")
    public DeleteAdministrationResult delectAreaType(@PathVariable("id") String id,
                                                     @RequestBody(required = true) AreaType areaType) {
        return areaTypeService.delectAreaType(id,areaType);
    }

    @Override
    @PutMapping("/edit/{id}")
    public ResponseResult editAreaType(@PathVariable("id") String id,
                                       @RequestBody AreaType areaType) {
        return areaTypeService.editAreaType(id,areaType);
    }
}
